#include "stdafx.h"
#include "CryptUtils.h"


CryptUtils::CryptUtils(void)
{
}

String^ CryptUtils::GetMD5(String^ input)
{
	MD5^ md5 = MD5::Create();
    String^ hash = "";
    array<unsigned char>^ s = md5->ComputeHash(Encoding::UTF8->GetBytes(input));
    for (int i = 0; i < s->Length; i++)
    {
            hash = hash + s[i].ToString("x");               
    }
	return hash;
}

String^ CryptUtils::GetMD5withPadding(String^ input, String^ padding)
{
	return GetMD5(padding+input+padding);
}

String^ CryptUtils::GetMD5Twice(String^ input)
{
	return GetMD5(GetMD5(input));
}

String^ CryptUtils::GetMD5TwicewithPadding(String^ input)
{
	return GetMD5withPadding(GetMD5withPadding(input,"##rjks_chaojibang##"),"##rjks_chaojibang##");
}